package com.zgc.entity;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
/**
 * 前端树形展示
 * */
@Data
public class TreeIndex implements Serializable {
    private Long id;
    private String name;
    private String url;
    private String icon;
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeIndex> children;
    public TreeIndex() {
    }
    public TreeIndex(Menu menu) {
        this.id=menu.getId();
        this.name=menu.getName();
        if(null !=menu.getChildren()) {
            this.children =
                    menu.getChildren().stream().map(TreeIndex::new).collect(Collectors.toList());
        }
        this.url=menu.getUrl();
        this.icon=menu.getIcon();
    }
}